home *** CD-ROM | disk | FTP | other *** search
/ Together in Jesus: 1st Eucharist Computer Fun / Together in Jesus - First Eucharist - Computer Fun.iso / flash-fix.js < prev    next >
Text File  |  2007-09-16  |  7KB  |  173 lines

  1. if(typeof com == "undefined") var com = new Object();
  2. if(typeof com.deconcept == "undefined") com.deconcept = new Object();
  3. if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
  4. if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
  5. com.deconcept.FlashObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  6.   if (!document.createElement || !document.getElementById) return;
  7.   this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  8.   this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  9.   this.params = new Object();
  10.   this.variables = new Object();
  11.   this.attributes = new Array();
  12.   this.useExpressInstall = useExpressInstall;
  13.  
  14.   if(swf) this.setAttribute('swf', swf);
  15.   if(id) this.setAttribute('id', id);
  16.   if(w) this.setAttribute('width', w);
  17.   if(h) this.setAttribute('height', h);
  18.   if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
  19.   this.installedVer = com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
  20.   if(c) this.addParam('bgcolor', c);
  21.   var q = quality ? quality : 'high';
  22.   this.addParam('quality', q);
  23.   var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  24.   this.setAttribute('xiRedirectUrl', xir);
  25.   this.setAttribute('redirectUrl', '');
  26.   if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
  27. }
  28. com.deconcept.FlashObject.prototype = {
  29.   setAttribute: function(name, value){
  30.     this.attributes[name] = value;
  31.   },
  32.   getAttribute: function(name){
  33.     return this.attributes[name];
  34.   },
  35.   addParam: function(name, value){
  36.     this.params[name] = value;
  37.   },
  38.   getParams: function(){
  39.     return this.params;
  40.   },
  41.   addVariable: function(name, value){
  42.     this.variables[name] = value;
  43.   },
  44.   getVariable: function(name){
  45.     return this.variables[name];
  46.   },
  47.   getVariables: function(){
  48.     return this.variables;
  49.   },
  50.   createParamTag: function(n, v){
  51.     var p = document.createElement('param');
  52.     p.setAttribute('name', n);
  53.     p.setAttribute('value', v);
  54.     return p;
  55.   },
  56.   getVariablePairs: function(){
  57.     var variablePairs = new Array();
  58.     var key;
  59.     var variables = this.getVariables();
  60.     for(key in variables){
  61.       variablePairs.push(key +"="+ variables[key]);
  62.     }
  63.     return variablePairs;
  64.   },
  65.   getFlashHTML: function() {
  66.     var flashNode = "";
  67.     if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
  68.       if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
  69.       flashNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
  70.       flashNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
  71.       var params = this.getParams();
  72.        for(var key in params){ flashNode += [key] +'="'+ params[key] +'" '; }
  73.       var pairs = this.getVariablePairs().join("&");
  74.        if (pairs.length > 0){ flashNode += 'flashvars="'+ pairs +'"'; }
  75.       flashNode += '/>';
  76.     } else { // PC IE
  77.       if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
  78.       flashNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
  79.       flashNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
  80.       var params = this.getParams();
  81.       for(var key in params) {
  82.        flashNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
  83.       }
  84.       var pairs = this.getVariablePairs().join("&");
  85.       if(pairs.length > 0) {flashNode += '<param name="flashvars" value="'+ pairs +'" />';}
  86.       flashNode += "</object>";
  87.     }
  88.     return flashNode;
  89.   },
  90.   write: function(elementId){
  91.     if(this.useExpressInstall) {
  92.      
  93.       var expressInstallReqVer = new com.deconcept.PlayerVersion([6,0,65]);
  94.       if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
  95.         this.setAttribute('doExpressInstall', true);
  96.         this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
  97.         document.title = document.title.slice(0, 47) + " - Flash Player Installation";
  98.         this.addVariable("MMdoctitle", document.title);
  99.       }
  100.     } else {
  101.       this.setAttribute('doExpressInstall', false);
  102.     }
  103.     if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
  104.       var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
  105.       n.innerHTML = this.getFlashHTML();
  106.     }else{
  107.       if(this.getAttribute('redirectUrl') != "") {
  108.         document.location.replace(this.getAttribute('redirectUrl'));
  109.       }
  110.     }
  111.   }
  112. }
  113.  
  114.  
  115. com.deconcept.FlashObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
  116.   var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
  117.   if(navigator.plugins && navigator.mimeTypes.length){
  118.     var x = navigator.plugins["Shockwave Flash"];
  119.     if(x && x.description) {
  120.       PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
  121.     }
  122.   }else{
  123.     try{
  124.       var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  125.       for (var i=3; axo!=null; i++) {
  126.         axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
  127.         PlayerVersion = new com.deconcept.PlayerVersion([i,0,0]);
  128.       }
  129.     }catch(e){}
  130.     if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; 
  131.     if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
  132.       try{
  133.         PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
  134.       }catch(e){}
  135.     }
  136.   }
  137.   return PlayerVersion;
  138. }
  139. com.deconcept.PlayerVersion = function(arrVersion){
  140.   this.major = parseInt(arrVersion[0]) || 0;
  141.   this.minor = parseInt(arrVersion[1]) || 0;
  142.   this.rev = parseInt(arrVersion[2]) || 0;
  143. }
  144. com.deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  145.   if(this.major < fv.major) return false;
  146.   if(this.major > fv.major) return true;
  147.   if(this.minor < fv.minor) return false;
  148.   if(this.minor > fv.minor) return true;
  149.   if(this.rev < fv.rev) return false;
  150.   return true;
  151. }
  152.  
  153. com.deconcept.util = {
  154.   getRequestParameter: function(param){
  155.     var q = document.location.search || document.location.hash;
  156.     if(q){
  157.       var startIndex = q.indexOf(param +"=");
  158.       var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
  159.       if (q.length > 1 && startIndex > -1) {
  160.         return q.substring(q.indexOf("=", startIndex)+1, endIndex);
  161.       }
  162.     }
  163.     return "";
  164.   }
  165. }
  166.  
  167.  
  168. if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
  169.  
  170.  
  171. var getQueryParamValue = com.deconcept.util.getRequestParameter;
  172. var FlashObject = com.deconcept.FlashObject;
  173.